package com.huabo.contract.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblLegalQualification;
import com.huabo.contract.oracle.mapper.TblLegalQualificationMapper;
import com.huabo.contract.service.TblLegalQualificationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblLegalQualificationServiceImpl implements TblLegalQualificationService {


    @Resource
    private TblLegalQualificationMapper tblLegalQualificationMapper;

    @Override
    public void findListByPageInfo(PageInfo<TblLegalQualification> pageInfo, TblLegalQualification qualification,Integer disputeid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalQualificationMapper.findListByPageInfo(pageInfo, qualification, disputeid));
            pageInfo.setTotalRecord(tblLegalQualificationMapper.findListByPageInfoCount(qualification, disputeid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("date", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalQualificationMapper.findListByPageInfo(pageInfo, qualification, disputeid));
            pageInfo.setTotalRecord(tblLegalQualificationMapper.findListByPageInfoCount(qualification, disputeid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("date", pageInfo);
        }
    }

    @Override
    public TblLegalQualification findById(Integer qualId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblLegalQualificationMapper.findByQualId(qualId);
        } else {
            return tblLegalQualificationMapper.findByQualId(qualId);
        }
    }

    @Override
    public void saveQualification(TblLegalQualification qualification) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalQualificationMapper.saveQualification(qualification);
        } else {
            tblLegalQualificationMapper.saveQualification(qualification);
        }
    }

    @Override
    public void updateModifyQualification(TblLegalQualification old) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalQualificationMapper.updateModifyQualification(old);
        } else {
            tblLegalQualificationMapper.updateModifyQualification(old);
        }
    }

    @Override
    public void removeQualification(Integer qualId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            this.tblLegalQualificationMapper.removeQualification(qualId);
        } else {
            this.tblLegalQualificationMapper.removeQualification(qualId);
        }
    }
}
